<!DOCTYPE html>
<html lang='zh-CN'>

<head>
  <meta charset='UTF-8'>
  <meta name='viewport'
    content='width=device-width, initial-scale=1.0, maximum-scale=1.0, shrink-to-fit=no,  viewport-fit=cover'>
  <title><%= title %></title>
  <link rel='stylesheet' href='/bootstrap/css/bootstrap.min.css' />
  <link rel='stylesheet' href='/font-awesome/css/font-awesome.min.css' />
  <style>
    .banner {
      width: 100%;
      max-width: 400px;
      /* margin: 0 auto; */
      overflow-y: auto;
    }

    .banner ul {
      /* width: 100%; */
      height: 160px;
      margin: 0;
      padding: 0;
      border: 4px solid black;
      position: relative;
      overflow: hidden;
    }

    .banner ul li {
      list-style: none;
      width: 100%;
      /* max-width: 100%; */
      height: 160px;
      background-color: darkgray;
      float: left;
      position: absolute;
      transition: all 0.6s;

      text-align: center;
      line-height: 136px;
      font-size: 32px;
      color: white;
    }

    .banner ul li:nth-of-type(2) {
      background-color: aqua;
    }

    .banner ul li:nth-of-type(3) {
      background-color: cadetblue;
    }
  </style>
</head>

<body>
  <div class="container">
    <div class="row">
      <div class="col-md-6 col-sm-12 m-auto">
        <h1> <%= title %> <small><a href="/swagger" target="_blank">swagaga</a></small></h1>

        <div class="banner mb-2">
          <ul>
            <li>1</li>
            <li>2</li>
            <li>3</li>
          </ul>
        </div>
        <button class="btn btn-primary left" type="button">
          <i class="fa fa-chevron-left" aria-hidden="true"></i>
        </button>
        <button class="btn btn-primary right" type="button">
          <i class="fa fa-chevron-right" aria-hidden="true"></i>
        </button>

        <!-- <form>
          <div class="input-group mb-3">
            <div class="input-group-prepend">
              <button class="btn btn-info">
                <i class="fa fa-user" aria-hidden="true"></i>
              </button>
            </div>
            <input class="form-control" id="user" name="user" placeholder="user">
          </div>

          <div class="input-group mb-3">
            <div class="input-group-prepend">
              <button class="btn btn-info">
                <i class="fa fa-lock" aria-hidden="true"></i>
              </button>
            </div>
            <input class="form-control" id="password" name="password" placeholder="password">
          </div>

          <button class="btn btn-info btn-lg btn-block" type="submit">submit</button>
        </form> -->

      </div>
    </div>
  </div>

  <script src="/jquery/jquery.min.js"></script>
  <script src="/bootstrap/js/bootstrap.min.js"></script>
  <script>
    function moveSide(i) {
      $(".banner ul li").each(function (item) {
        $(".banner ul li:eq(" + item + ")").css("left", ((item + i) * -337) + (item * 2 * 337) + 0 + "px");
      })
    }
    
    $(document).ready(function () {

      var index = 0;
      $(".banner ul li").each(function (e) {
        $(".banner ul li:eq(" + e + ")").css("left", e * 337 + 0 + "px");
      })

      $("button.left").click(function () {
        index--
        index = index < 0 ? $(".banner ul li").length - 1 : index;
        console.log(index)
        moveSide(index)
      })

      $("button.right").click(function () {
        index++;
        index = index > $(".banner ul li").length - 1 ? 0 : index;
        console.log(index)
        moveSide(index)
      })

      setInterval(function () {
        index++;
        index = index > $(".banner ul li").length - 1 ? 0 : index;
        console.log(index)
        moveSide(index)
      }, 5000)

      $("form").submit(function (e) {
        e.preventDefault();
        let _this = $("form")
        console.table(_this.serialize());

        $.ajax({
          url: "/user/post-mongo?" + $(this).serialize(),
          method: 'post',
          async: false
        }).then(res => {
          // console.log(res);
        })
      })

    })
  </script>
</body>

</html>